Skip to content

fix(FR_O): handle new live fields, MQ solar, and historical schema - #8742

Open
VIKTORVAV99 wants to merge 3 commits into
masterfrom
vik/fix-fr-o-mode-keys
Open

fix(FR_O): handle new live fields, MQ solar, and historical schema#8742
VIKTORVAV99 wants to merge 3 commits into
masterfrom
vik/fix-fr-o-mode-keys

Conversation

@VIKTORVAV99

@VIKTORVAV99 VIKTORVAV99 commented May 27, 2026

Copy link
Copy Markdown
Member

Problem

Several issues surfaced in the FR_O parser (FR-COR, RE, GF, MQ, GP):

  1. Unknown mode_key: 'part_liaisons' warnings (FR-COR) — the live dataset added aggregate sub-totals (filiere_*) and percentage shares (part_*) alongside the per-mode values. They were logged as unknown modes (and risked being double-counted).
  2. MQ dropped solar — Martinique's live feed now reports photovoltaique, but the MQ mapping had no entry for it, so solar was silently discarded and logged as unknown.
  3. Historical production was completely broken — fetches with a target_datetime hit a different national dataset (courbe-de-charge-de-la-production-delectricite-par-filiere) whose *_mw schema shares no keys with the live mappings. Every historical record failed with Mix is completely empty, returning 0 events plus a flood of warnings.

Fix

  • Ignore filiere_* / part_* (via prefix) and date_jour.
  • Add photovoltaique → solar to the MQ mapping.
  • Add a dedicated historical mapping for the national *_mw schema, selected when target_datetime is set. The national feed lumps thermal (oil/gas) into thermique_mw and bagasse/coal into bagasse_charbon_mw — neither can be split, so both map to the unknown mode (documented inline). On the historical path the storage value is negated inside the add_value call so the frequently-null stockage_mw passes through to the model's internal None handling instead of crashing on the unary minus.

Tests

  • Refreshed every zone's mock with real API samples; removed the stale synthetic FR_GP.json (wrong key) and orphaned FR_COR.json.
  • Per-zone production snapshot tests + a historical snapshot test, split into individual files via SingleFileAmberSnapshotExtension.
  • Each test asserts logger.warning is never called, so any unhandled key (new aggregate field or unmapped mode) fails the test. Verified: reverting each fix makes the corresponding test fail.

Known follow-up (not in this PR)

Discussed separately as a future improvement: live and historical mappings are not aligned and can't be fully unified — the national (historical) feed is lower-resolution and can't reproduce the live oil/gas/coal split, so historical thermal stays unknown. Current behaviour is intentionally preserved here. A related pre-existing question — RE's live charbon→biomass / diesel→biomass mapping — is also left untouched for that future discussion.

🤖 Generated with Claude Code

The FR-COR live dataset added aggregate sub-totals (filiere_*) and
percentage shares (part_*) that were logged as unknown mode_keys. Ignore
these (and date_jour) so they are neither warned about nor double counted.

Martinique's live feed now reports photovoltaique; add it to the MQ
mapping so solar is no longer dropped.

Historical production (target_datetime) was completely broken: it hits a
different national dataset whose *_mw schema shares no keys with the live
mappings, so every record failed with an empty mix. Add a dedicated
historical mapping. The national feed lumps thermal (oil/gas) and
bagasse/coal into single values that cannot be split, so both map to the
unknown mode. Also guard storage against the frequently-null stockage_mw.

Refresh all zone mocks with real samples and add per-zone snapshot tests
(SingleFileAmberSnapshotExtension) plus a historical snapshot test; each
asserts no warning is logged so unhandled keys are caught.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@VIKTORVAV99
VIKTORVAV99 requested a review from a team as a code owner May 27, 2026 13:44
@github-actions github-actions Bot added the python Pull requests that update Python code label May 27, 2026
VIKTORVAV99 and others added 2 commits June 1, 2026 13:30
stockage_mw is frequently null and tiny when present; treating it as an
ignored value avoids needing a special-case null guard on the storage
path and keeps the live storage handling unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
stockage_mw is mapped on the historical path as well. The unary minus on
production_object[mode_key] crashes when the value is null (which it is
for most island records on the national feed), so the negation moves
inside the add_value argument and passes None through unchanged - which
add_value already handles internally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
"bioenergies_mw": "biomass",
"geothermie_mw": "geothermal",
"thermique_mw": "unknown",
"bagasse_charbon_mw": "unknown",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think bagasse_charbon is a type of biomass. "dry pulpy fibrous material that remains after crushing sugarcane or sorghum stalks to extract their juice. It is used as a biofuel for the production of heat, energy, and electricity, and in the manufacture of pulp and building materials."

@PaulRoms PaulRoms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment other LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants